﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _6 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "ParentId",
                table: "SysFileInfo");

            migrationBuilder.UpdateData(
                table: "SysFileInfo",
                keyColumn: "FileSize",
                keyValue: null,
                column: "FileSize",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "FileSize",
                table: "SysFileInfo",
                type: "longtext",
                nullable: false,
                comment: "文件大小",
                oldClrType: typeof(double),
                oldType: "double",
                oldNullable: true,
                oldComment: "文件大小（kb）")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "BusinessId",
                table: "SysFileInfo",
                type: "varchar(50)",
                maxLength: 50,
                nullable: false,
                defaultValue: "",
                comment: "业务绑定ID")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "BusinessType",
                table: "SysFileInfo",
                type: "varchar(50)",
                maxLength: 50,
                nullable: false,
                defaultValue: "",
                comment: "业务来源")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<Guid>(
                name: "FolderId",
                table: "SysFileInfo",
                type: "char(36)",
                nullable: true,
                comment: "文件夹Id",
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<string>(
                name: "HashFileName",
                table: "SysFileInfo",
                type: "varchar(500)",
                maxLength: 500,
                nullable: false,
                defaultValue: "",
                comment: "文件名称")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<bool>(
                name: "IsSystemFile",
                table: "SysFileInfo",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "是否系统文件");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "BusinessId",
                table: "SysFileInfo");

            migrationBuilder.DropColumn(
                name: "BusinessType",
                table: "SysFileInfo");

            migrationBuilder.DropColumn(
                name: "FolderId",
                table: "SysFileInfo");

            migrationBuilder.DropColumn(
                name: "HashFileName",
                table: "SysFileInfo");

            migrationBuilder.DropColumn(
                name: "IsSystemFile",
                table: "SysFileInfo");

            migrationBuilder.AlterColumn<double>(
                name: "FileSize",
                table: "SysFileInfo",
                type: "double",
                nullable: true,
                comment: "文件大小（kb）",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldComment: "文件大小")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<Guid>(
                name: "ParentId",
                table: "SysFileInfo",
                type: "char(36)",
                nullable: true,
                comment: "父节点",
                collation: "ascii_general_ci");
        }
    }
}
